package com.example.prison.mapper;

import com.example.prison.entity.AreaRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author jiang
* @description 针对表【area_record】的数据库操作Mapper
* @createDate 2023-06-07 10:30:19
* @Entity com.example.prison.entity.AreaRecord
*/
@Mapper
public interface AreaRecordMapper extends BaseMapper<AreaRecord> {

    @Select("<script>select * from area_record " +
            " <where> " +
            " <if test=\"defenseSection != null and defenseSection != ''\">and defense_section like concat('%',#{defenseSection},'%') </if> " +
            " <if test=\"alarmStatus != null and alarmStatus != ''\">and alarm_status like concat('%',#{alarmStatus},'%') </if> " +
            " <if test=\"deviceNumber != null and deviceNumber != ''\">and device_number like concat('%',#{deviceNumber},'%') </if> " +
            " <if test=\"beginTime != null and beginTime != ''\">and time &gt;= #{beginTime} </if> " +
            " <if test=\"endTime != null and endTime != ''\">and time &lt;= #{endTime} </if> " +
            " </where> " +
            "order by id desc</script>")
    List<AreaRecord> get(@Param("defenseSection")String defenseSection,@Param("alarmStatus")String alarmStatus,
                         @Param("deviceNumber")String deviceNumber,@Param("beginTime")String beginTime,@Param("endTime")String endTime);

    @Insert("insert into area_record(defense_section,defense_section_point,sentry_post,sentry_address,time,status,voltageA,currentA,voltageB,currentB,voltageC,currentC," +
            "high_rated_voltage,rated_current,rated_voltage,alarm_level,alarm_status,device_number,linear_voltageAB,linear_voltageAC,linear_voltageBC,mark_id,statusA,statusB,statusC) " +
            "values (#{defenseSection},#{defenseSectionPoint},#{sentryPost},#{sentryAddress},#{time},#{status},#{voltageA},#{currentA},#{voltageB},#{currentB},#{voltageC}," +
            "#{currentC},#{highRatedVoltage},#{ratedCurrent},#{ratedVoltage},#{alarmLevel},#{alarmStatus},#{deviceNumber},#{linearVoltageAB},#{linearVoltageAC},#{linearVoltageBC}," +
            "#{MarkId},#{statusA},#{statusB},#{statusC})")
    int add(AreaRecord record);


}




